import { Injectable } from '@angular/core';
import {CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, Router} from '@angular/router';

@Injectable()
export class MasterGuard implements CanActivate {
  constructor(private router: Router) {
  }

  canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
    const isCanActivate = window.sessionStorage.getItem('isCanActivate');
    if (isCanActivate === 'true') {
      return true;
    } else {
      this.router.navigateByUrl('login');
      return true;
    }
  }
}
